package com.ftg.learn.rbac.controller;

import com.ftg.learn.rbac.entity.User;
import com.ftg.learn.rbac.service.IUserService;
import com.ftg.learn.util.BaseController;
import com.ftg.learn.util.ResEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 解决跨域访问 在后台添加白名单
 * 在白名单里指定前台服务器的ip和端口号。
 * @author Guo
 * @date 2022/2/8
 */
@RestController
@RequestMapping("/rbac/user")
@Api(tags = "用户管理功能列表")
public class UserController extends BaseController<User, IUserService> {


    @GetMapping("/showRoleForUserId")
    @ApiOperation(value = "查某个人具有的角色")
    public ResEntity showRoleForUserId(@RequestParam Long uid) {
        return new ResEntity(0, "success", super.service.showRoleForUserId(uid));
    }


    @PostMapping("/roleGroup")
    @ApiOperation(value = "对操作的用户删除角色及添加新角色")
    public ResEntity roleGroup(@RequestParam List<Long> rid, @RequestParam Long uid) {
        return new ResEntity(0, "success", super.service.roleGroup(rid, uid));
    }

}
